// Logic 0: Main logic

#include "defines.txt"

if (error_code > 0) {
  call(error_handler);
}

if (room_no == 0 && !game_restarted) {
  call(initialize);
  new.room(opening_screen);
}

if (room_no == 0 && game_restarted) {
  call(initialize);
  new.room(beach);
}

if (new_room) {
  load.logics(global_actions);
  load.logics(menus_and_ego_anim);
  load.logics(death_handler);
  if (debug_active) {
    load.logics(debug);
  }
}

if (death_type != none) {
  call(death_handler);
}

if (death_type == none) {
  call(menus_and_ego_anim);
  call.v(room_no);
  if (debug_active) {
    call(debug);
  }
  call(global_actions);
}

return();